<%@page contentType="text/html; charset=utf-8"%>
<%@ include file="../inc/TagLibs.jsp"%>
<c:set var="pageTitle" value="外协单打印" />
<%@ include file="../inc/PrintTitle.jsp"%>
<head>
<script src="/js/popup_ext.js"></script>
<script language="javascript">
	function doCancel(){
		window.close();
	}
	function doPrint(){
		ShowConfirm('确认框','确定开始打印吗？',340,80,"doPrintCallBack()");
	}
	function doPrintCallBack(){
		if(popRetVal!=null){
			document.getElementById("noPrinSpan").style.display="none";
			printContent("管理易-外协单","${enterpriseInfo.doPrint}","${enterpriseInfo.printWidth}");
			document.getElementById("noPrinSpan").style.display="";
		}
	}
	function showTotalDiv(imprest,favCost,cost,adjuCost,paiedCost,exam,divId){
		var str="";
		if(favCost==0){
			str=str+"&nbsp;<b>合计(大写):</b>";
		}else{
			str=str+"&nbsp;<b>优惠:</b>"+favCost+"</b>&nbsp;<b>折后合计(大写):</b>";
		}
		str=str+getBigMoney(""+cost);
		str=str+"<b>￥</b>"+cost+"&nbsp;";
		str=str+"<b>已调账:</b>"+adjuCost+"&nbsp;";
		str=str+"<b>已付款:</b>";
		if(exam=='Y'){
			str=str+paiedCost+"&nbsp;";
		}else{
			str=str+imprest+"&nbsp;";
		}
		str=str+"<b>尚欠金额:</b>";
		if(exam=='Y'){
			str=str+parseScale(abateMul(addMul(cost,adjuCost),paiedCost),2)+"&nbsp;";
		}else{
			str=str+parseScale(abateMul(addMul(cost,adjuCost),imprest),2)+"&nbsp;";
		}
		document.getElementById(divId).innerHTML=str;
	}
</script>
</head>
<body style="background-color:#FFFFFF">
<table width="100%" border="0"  align="center" cellpadding="0" cellspacing="0">
	<tr>
		<td>
			<table width="98%" border="0" cellspacing="1" cellpadding="1" align="center">
				<tr>
					<td width="16%" rowspan="2"><img src="${enterpriseInfo.loginImage}" /></td>
					<td width="68%" height="40px" align="center" class="FontLarge_Bold">${licenseInfo.enterpriseName} 外协单</td>
					<td width="16%">&nbsp;</td>
				</tr>
				<tr>
				  <td colspan="2" align="right" valign="bottom" class="FontSmall">NO.&nbsp;${record.cooperBill.billCode}</td>
			  	</tr>
		  </table>
		</td>
	</tr>
	<tr>
		<td>
			<table width="98%" border="0" align="center" cellpadding="0" cellspacing="0" class="ListTable">
				<tr class="ListTrPrint">
			      	<td class="FontSmall" width="70%">外协单位：${record.cooperatorName} ${record.cooperBill.linkman} ${record.cooperBill.phone}</td>
			      	<td class="FontSmall" width="30%" align="right">外协日期：<fmt:formatDate value="${record.cooperBill.cooperDate}" pattern="yyyy-MM-dd"/></td>
				</tr>
				<tr class="ListTrPrint">
				  	<td class="FontSmall" colspan="2" align="right">交货日期：<c:if test="${record.cooperBill.gatherDate!=null}"><fmt:formatDate value="${record.cooperBill.gatherDate}" pattern="yyyy-MM-dd"/></c:if></td>
			  </tr>
		  </table>
		</td>
	</tr>
	<tr>
		<td height="3"></td>
	</tr>
	<tr>
		<td>
			<table width="98%" border="0" align="center" cellpadding="0" cellspacing="0" class="small_border">
				<tr class="ListTrPrint">
				  <td width="10%" height="23" class="FontSmall_Bold"><div align="center">项目类型</div></td>
				  <td width="14%" class="FontSmall_Bold"><div align="center">内容</div></td>
				  <td width="12%" class="FontSmall_Bold"><div align="center">材质</div></td>
				  <td width="14%" class="FontSmall_Bold"><div align="center">规格</div></td>
				  <td width="6%" class="FontSmall_Bold"><div align="center">单位</div></td>
				  <td width="7%" class="FontSmall_Bold"><div align="center">数量</div></td>
				  <td width="7%" class="FontSmall_Bold"><div align="center">单价</div></td>
				  <td width="8%" class="FontSmall_Bold"><div align="center">金额</div></td>
				  <td width="12%" class="FontSmall_Bold"><div align="center">制作要求</div></td>
				  <td width="10%" class="FontSmall_Bold"><div align="center">业务单号</div></td>
				</tr>
				<c:forEach var="item" items="${record.items}" varStatus="i">
				<tr class="ListTrPrint">
				  <td class="FontSmall"><div align="center">${item.makeTypeName}</div></td>
				  <td class="FontSmall"><div align="center"><commonTag:parseEnterToBr source="${item.cooperBillItem.finishedContent}" /></div></td>
				  <td class="FontSmall"><div align="center">${item.cooperBillItem.proName}</div></td>
				  <td class="FontSmall">
					  <div align="center">
						  <commonTag:parseEnterToBr source="${item.cooperBillItem.specification}" />
						  <c:if test="${item.cooperBillItem.priceType=='AREA' || item.cooperBillItem.priceType=='LENGTH'}"> x <commonTag:parseBigDecimal source="${item.cooperBillItem.amount}" /></c:if>
					  </div>
				  </td>
				  <td class="FontSmall">
					  <div align="center">
					  	<c:if test="${item.cooperBillItem.priceType=='AREA'}">平方米</c:if>
						<c:if test="${item.cooperBillItem.priceType=='LENGTH'}">
							<c:if test="${item.cooperBillItem.lengType=='M'}">米</c:if><c:if test="${item.cooperBillItem.lengType=='CM'}">公分</c:if>
						</c:if>
						<c:if test="${item.cooperBillItem.priceType=='AMOUNT'}">${item.cooperBillItem.unit}</c:if>
					  </div>
				  </td>
				  <td class="FontSmall">
					  <div align="center">
					  	<c:if test="${item.cooperBillItem.priceType=='AREA' || item.cooperBillItem.priceType=='LENGTH'}"><commonTag:parseBigDecimal source="${item.cooperBillItem.squareNum}" /></c:if>
						<c:if test="${item.cooperBillItem.priceType=='AMOUNT'}"><commonTag:parseBigDecimal source="${item.cooperBillItem.amount}" /></c:if>
					  </div>
				  </td>
				  <td class="FontSmall"><div align="center"><commonTag:parseBigDecimal source="${item.cooperBillItem.unitPrice}" /></div></td>
				  <td class="FontSmall"><div align="center"><commonTag:parseBigDecimal source="${item.cooperBillItem.cost}" /></div></td>
				  <td class="FontSmall"><div align="center"><commonTag:parseEnterToBr source="${item.cooperBillItem.makeRequire}" /></div></td>
				  <td class="FontSmall"><div align="center"><commonTag:parseEnterToBr source="${item.cooperBillItem.bbCode}" /></div></td>
				</tr>
				</c:forEach>
			  <tr  class="ListTrPrint">
				  <td class="FontSmall" colspan="10">
					<div align="right" id="totalDiv"></div>
				  </td>
			  </tr>	
		  </table>
		</td>
	</tr>
	<tr>
		<td height="3"></td>
	</tr>
	<tr>
		<td>
			<table width="98%" border="0" align="center" cellpadding="0" cellspacing="0" class="small_border">
				<tr class="ListTrPrint">
			      	<td class="FontSmall_Bold" width="10%">交货要求</td>
			      	<td class="FontSmall" width="40%">${record.cooperBill.gatherRequire}</td>
			      	<td class="FontSmall_Bold" width="10%">安装要求</td>
			      	<td class="FontSmall" width="40%">${record.cooperBill.setupRequire}</td>
				</tr>
				<tr class="ListTrPrint">
					<td class="FontSmall_Bold">备注</td>
			      	<td class="FontSmall" colspan="3">${record.cooperBill.mark}</td>
				</tr>
		  </table>
		</td>
	</tr>
	<tr>
		<td height="3"></td>
	</tr>
	<tr>
		<td>
			<table width="98%" border="0" cellspacing="0" cellpadding="0" align="center" class="ListTable">
				<tr class="ListTrPrint">
					<td class="FontSmall" width="33%">开单人:${record.cooperBill.createrName}</td>
					<td class="FontSmall" width="33%">审核人:${record.cooperBillExt.examinerName}</td>
					<td class="FontSmall" width="34%">签名:</td>
				</tr>
		  </table>
		</td>
	</tr>
	<tr>
		<td height="3"></td>
	</tr>
	<c:if test="${codeRule.printFoot!=null && codeRule.printFoot!=''}">
	<tr>
		<td>
			<table width="98%" border="0" cellspacing="1" cellpadding="1" align="center">
				<tr>
					<td class="FontSmall"><commonTag:parseEnterToBr source="${codeRule.printFoot}" /></td>
				</tr>
			</table>
		</td>
	</tr>
	</c:if>
</table>
<table width="100%" border="0" align="center" cellpadding="0" cellspacing="0" id="noPrinSpan">
	<tr>
		<td>
			<table width="98%" border="0" cellspacing="1" cellpadding="1" align="center">
				<tr>
					<td>
						<input type="button" id="printButton" class="Button" value="开始打印" onClick="doPrint();">
						<input type="button" id="cancelButton" class="Button" value=" 退 出 " onClick="doCancel();">
					</td>
				</tr>
			</table>
		</td>
	</tr>
</table>
</body>
</html>
<script language="javascript">
	showTotalDiv(${record.cooperBill.imprest},${record.cooperBill.favCost},${record.cooperBill.cost},${record.cooperBillExt.adjustCost},${record.cooperBillExt.paiedCost},'${record.cooperBillExt.examined}','totalDiv');
</script>